/*
 * mkdir.scala
 */

package acorn.jash.commands

import acorn.jash.Cmd
import acorn.jash.{Shell}

class mkdir extends Cmd {

  override def exec {
    if (args == Nil) println("Please specify directories to be created.")
    else args.foreach{p=>if(!(p startsWith "-")) mkdir(p)}
  }

  private def mkdir(p:String) {
    val dir = Shell.wd changeTo p
    val file = dir asFile;
    if (!file.exists && file.mkdirs)
      println("Created " + dir.realpath)
  }
}
